import calendar from "../calendar/calendar.vue"
import {mapActions, mapGetters, mapMutations, mapState} from "vuex"
import {dateInfo, _thisWeek} from "../../js/date"

export default {
  name: 'index',
  data() {
    return {
      countSwitch: false,
      countShow:true
    }
  },
  methods: {
    ...mapMutations([
      '_thisWeekList',
      'titleM',
    ]),
    ...mapActions([
      '_title',
      '_dateList',
    ]),
    init() {
      this.getDateList();
    },
    getDateList() {
      let y = new Date().getFullYear();
      let m = new Date().getMonth() + 1;
      let d = dateInfo.getMonthData(y, m);
      let w = _thisWeek();
      this._dateList(d);
      this._thisWeekList(w);
    },
    swCount(){
      this.countSwitch = !this.countSwitch;
      if (this.countSwitch){
        this.countShow = false;
        let a =  Math.max.apply(null,this.countAllReport.map((i)=>{
          return i.p.length;
        }));
        a = a > 8 ? 8 : a;
        this.$refs.cn.style.height = a * 20 + 60 + "px";
        this.$refs.cn.style.borderRadius = "4px";
      }else {
        this.$refs.cn.style.height = "29px";
        this.$refs.cn.style.borderRadius = "16px";
        setTimeout(()=>{
          this.countShow = true;
        },250)
      }
    },
    goDetail(id){
      let data1 = [
        {
          text: '输出',
          value: 'a'
        }, {
          text: '控制',
          value: 'b'
        },
        {
          text: '核心',
          value: 'c'
        },
        {
          text: '爆发',
          value: 'd'
        },
        {
          text: '辅助',
          value: 'e'
        },
        {
          text: '打野',
          value: 'f'
        },
        {
          text: '逃生',
          value: 'g'
        }, {
          text: '先手',
          value: 'h'
        }
      ]
      let data2 = [
        {
          text: '输出',
          value: 'a'
        }, {
          text: '控制',
          value: 'b'
        },
        {
          text: '核心',
          value: 'c'
        },
        {
          text: '爆发',
          value: 'd'
        },
        {
          text: '辅助',
          value: 'e'
        },
        {
          text: '打野',
          value: 'f'
        },
        {
          text: '逃生',
          value: 'g'
        }, {
          text: '先手',
          value: 'h'
        }
      ]
      this._pickerY({
        // data:[data1,data2],
        type:2,
        // selectedIndex:[0,1],
        onConfirm:(v)=>{
          console.log(v);
        }
      });
      // this.$router.push({name: "indexDetail", params: {id: id}});
    }
  },
  computed: {
    ...mapGetters([
      'title',
    ]),
    ...mapState([
      'thisWeekList',
      'countAllReport',
      'countDate',
      'needSendList',
      'receivedList',
    ])
  },
  created(){
    this.init();
  },
  activated() {
    this._title("工作日志");
  },
  components: {
    calendar,
  },
}
